#include "xconfig.h"
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

bool XConfig::Read(const string& file)
{
	ifstream ifs(file);
	if (!ifs.is_open()) return false;

	string line;
	for (;;)
	{
		getline(ifs, line);
		string key, value;
		if (!line.empty())
		{
			auto e_pos = line.find("=");
			if (e_pos != string::npos && e_pos > 0)
			{
				key = line.substr(0, e_pos);
				value = line.substr(e_pos + 1);
				conf_map_[key] = value;
			}
		}

		if (!ifs.good()) break;
	}

	return true;
}